<?php

Raise::load('core.IRaiseComparator');

/**
 * TestCoreIRaiseComparator
 * testing unit of 'phpraise/core/IRaiseComparable.php'
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreIRaiseComparator extends RaiseTest {

    public static function testInterface(){
        self::assertInterfaceExists('IRaiseComparator');
        self::assertClassExists('MockComparator');
        self::assertClassImplements('MockComparator', 'IRaiseComparator');
        self::assertClassMethod('MockComparator', 'compare');
    }

    public static function testCompare(){
        $arr1 = array('v' => 5, 'a' => 2034);
        $arr2 = array('v' => 10, 'a' => 534);

        $comparator = new MockComparator();
        self::assertObjectClass($comparator, 'MockComparator');
        $comparator->column('v');
        self::assertStrictEqual($comparator->compare($arr1, $arr2), -1);
        self::assertStrictEqual($comparator->compare($arr2, $arr1), 1);
        $comparator->column('a');
        self::assertStrictEqual($comparator->compare($arr1, $arr2), 1);
        self::assertStrictEqual($comparator->compare($arr2, $arr1), -1);
    }

}